#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@version: 1.0
@author: xjl
@file: 克隆设计模式.py
@time: 2022/10/7 9:15
"""

from copy import copy, deepcopy

class Person:
    "人"

    def __init__(self, name, age):
        self.__name = name
        self.__age = age

    def showMyself(self):
        print("我是" + self.__name + ",年龄" + str(self.__age) + ".")

    def coding(self):
        print("我是码农，我在Coding改变世界...")

    def reading(self):
        print("阅读使我快乐！知识使我成长！如饥似渴地阅读是生活的一部分...")

    def fallInLove(self):
        print("春风吹，月亮明，花前月下好相约...")

    def clone(self):
        return copy(self)

class Person:
    "人"

    def __init__(self, name, age):
        self.__name = name
        self.__age = age
        self.__petList = []

    def showMyself(self):
        print("我是" + self.__name + ",年龄" + str(self.__age) + ". 我养了这些宠物：")
        for pet in self.__petList:
            print(pet + "\t", end="")
        print()

    def addPet(self, pet):
        self.__petList.append(pet)

    def clone(self):
        return copy(self)

    def deepClone(self):
        return deepcopy(self)

def testProtoType():
    tony = Person("Tony", 26)
    tony.showMyself()
    tony.coding()

    tony1 = tony.clone()
    tony1.showMyself()
    tony1.reading()

    tony2 = tony.clone()
    tony2.showMyself()
    tony2.fallInLove()

if __name__ == '__main__':
    pass
